package org.thotheolh.sweatkeeper.ui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.border.TitledBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.UIManager;
import java.awt.Color;
import javax.swing.border.LineBorder;
import javax.swing.JTextArea;
import net.miginfocom.swing.MigLayout;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class GymWorkout extends JFrame {

	private JPanel contentPane;
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					GymWorkout frame = new GymWorkout();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public GymWorkout() {
		setTitle("Gym Workout Session");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		JPanel mainPanel = new JPanel();
		contentPane.add(mainPanel, BorderLayout.CENTER);
		mainPanel.setLayout(new BorderLayout(0, 0));
		
		JPanel commentsPane = new JPanel();
		commentsPane.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0)), "Comments: ", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
		mainPanel.add(commentsPane, BorderLayout.SOUTH);
		commentsPane.setLayout(new MigLayout("", "[grow][][][][][][][][][][][]", "[grow][][][]"));
		
		JScrollPane scrollPane = new JScrollPane();
		commentsPane.add(scrollPane, "cell 0 0 12 4,grow");
		
		JTextArea textArea = new JTextArea();
		textArea.setWrapStyleWord(true);
		textArea.setLineWrap(true);
		textArea.setRows(6);
		scrollPane.setViewportView(textArea);
		
		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0)), "Workout Exercises: ", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		mainPanel.add(panel, BorderLayout.CENTER);
		panel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane_1 = new JScrollPane();
		panel.add(scrollPane_1, BorderLayout.CENTER);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"SET #", "SEQUENCE #", "EXERCISE NAME", "EQUIPMENT", "WEIGHT", "REPS", "DISTANCE", "TIME"
			}
		));
		scrollPane_1.setViewportView(table);
		
		JPanel exeCtrlPane = new JPanel();
		FlowLayout flowLayout = (FlowLayout) exeCtrlPane.getLayout();
		flowLayout.setAlignment(FlowLayout.RIGHT);
		panel.add(exeCtrlPane, BorderLayout.SOUTH);
		
		JButton btnDeleteExercise = new JButton("Delete Exercise");
		exeCtrlPane.add(btnDeleteExercise);
		
		JButton btnNewExercise = new JButton("New Exercise");
		btnNewExercise.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
			}
		});
		exeCtrlPane.add(btnNewExercise);
		
		JPanel bottomPanel = new JPanel();
		contentPane.add(bottomPanel, BorderLayout.SOUTH);
		bottomPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
		
		JButton btnSaveButton = new JButton("Discontinue & Save");
		btnSaveButton.setToolTipText("Saves and discontinue workout for later use.");
		bottomPanel.add(btnSaveButton);
		
		JButton btnEndWorkout = new JButton("Workout Completed");
		btnEndWorkout.setToolTipText("Completion of workout session.");
		bottomPanel.add(btnEndWorkout);
	}

}
